#ifndef _DRONEPARAM_H
#define _DRONEPARAM_H

#include "stm32f4xx.h"

typedef enum
{
	Drone_Mode_None = 0,
	Drone_Mode_Pitch = 1, 	  //Pitch 外环实验
	Drone_Mode_Roll = 2,	  //Roll 外环实验
	Drone_Mode_4Axis = 3,	  //四轴平衡
	Drone_Mode_RatePitch = 4, //Pitch内环实验
	Drone_Mode_RateRoll = 5,  //Roll 内环实验
} DroneFlightMode_TypeDef;

typedef enum
{
	Drone_Off = 0x00,  //关闭电机
	Drone_On = 0x01,   //起飞或者调试打开电机
	Drone_Land = 0x02, //降落
} DroneFlightOnOff_TypeDef;

typedef enum
{
	Report_SET = 0x01,
	Report_RESET = 0x00,
} DroneReportSW_TypeDef;

//飞行器控制参数
typedef struct
{
	DroneFlightOnOff_TypeDef OnOff;		//控制飞行器开关
	DroneFlightMode_TypeDef droneMode;	//设置飞行器模式
	DroneReportSW_TypeDef ReportSW;		//飞行器上报参数开关
	int landFlag;						//飞行器将来开关
} DroneFlightControl;

//飞行器PID控制的期望值
typedef struct
{
	float Pitch;
	float Roll;
	float Yaw;
	float RateRoll;
	float RatePitch;
	float RateYaw;
	float Height;
	float AccHeight;
} DroneTargetInfo;

typedef struct
{
	float feedforwardOut; //前馈控制输出
	float pOut;
	float iOut;
	float dOut;
	float value; //PID控制输出
	
	int iOut_limit_max;
	int iOut_limit_min;
	int dOut_limit_max;
	int dOut_limit_min;
	int limit_min;
	int limit_max;
	
	
} PIDOut;

typedef struct
{
	float Kp;
	float Ki;
	float Kd;
} PID;

typedef struct 
{
	float Erro;
	float Last_Erro;
	float Last_Erro_Delta;
}PID_Erro;

//四旋翼PID参数
typedef struct
{
	//角度环
	PID Pitch;	
	PID Roll;
	PID Yaw;
	PID Height;
	
	//角速度环
	PID ratePitch;
	PID rateRoll;
	PID rateYaw;
	PID HeightRate;
	
	PID_Erro Pitch_Erro;
	PID_Erro Roll_Erro;
	PID_Erro Yaw_Erro;
	PID_Erro Height_Erro;
	
	PID_Erro PitchRate_Erro;
	PID_Erro RollRate_Erro;
	PID_Erro YawRate_Erro;
	PID_Erro HeightRate_Erro;
	
	PID rateX;
	PID rateY;
	PID_Erro rateX_Erro;
	PID_Erro rateY_Erro;
} DronePIDPara;

/* 平地误差数据，就是飞行器未起飞时在水平面的角度 */
typedef struct
{
	float fixedErroPitch;
	float fixedErroRoll;
	float fixedErroYaw;
} DroneErrangle;

/*水平遥控信息*/
typedef struct
{
	float pV; //x轴速度
	float rV; //y轴速度
	float hV; //z轴速度
	float yV; //yaw速度
} Controller;

/*无人机实时信息*/
typedef struct
{
	float Pitch;
	float Roll;
	float Yaw;
	float batteryVoltage;
	float ratePitch;   //Pitch轴的角速度
	float rateRoll;	   //Roll轴的角速度
	float rateYaw;	   //Yaw轴的角速度
	float US100_Alt;   //US100超声波高度
	float US100_Alt_V; //US100超声波速度
	float LASER_Alt;   //激光测距高度
	float LASER_Alt_V; //激光测距的速度
	float FlowX;	   //光流位置X
	float FlowY;	   //光流位置Y
	float FlowX_V;	   //光流速度X
	float FlowY_V;	   //光流速度Y
	int lowPowerFlag;  //低电压标志位
} DroneRTInfo;

//电机输出的基础量
typedef struct
{
	unsigned int M1;
	unsigned int M2;
	unsigned int M3;
	unsigned int M4;
} Throttle;



#endif
